package com.traffic.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.traffic.domain.PerOverseasApplication;
import com.traffic.service.IPerOverseasApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 出境申请Controller
 * 
 * @author 郭世纪
 * @date 2024-12-08
 */
@RestController
@RequestMapping("/overseas")
public class PerOverseasApplicationController extends BaseController
{
    @Autowired
    private IPerOverseasApplicationService perOverseasApplicationService;

    /**
     * 查询出境申请列表
     */
    @RequiresPermissions("document:overseas:list")
    @GetMapping("/list")
    public TableDataInfo list(PerOverseasApplication perOverseasApplication)
    {
        startPage();
        List<PerOverseasApplication> list = perOverseasApplicationService.selectPerOverseasApplicationList(perOverseasApplication);
        return getDataTable(list);
    }

    /**
     * 导出出境申请列表
     */
    @RequiresPermissions("document:overseas:export")
    @Log(title = "出境申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerOverseasApplication perOverseasApplication)
    {
        List<PerOverseasApplication> list = perOverseasApplicationService.selectPerOverseasApplicationList(perOverseasApplication);
        ExcelUtil<PerOverseasApplication> util = new ExcelUtil<PerOverseasApplication>(PerOverseasApplication.class);
        util.exportExcel(response, list, "出境申请数据");
    }

    /**
     * 获取出境申请详细信息
     */
    @RequiresPermissions("document:overseas:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(perOverseasApplicationService.selectPerOverseasApplicationById(id));
    }

    /**
     * 新增出境申请
     */
    @RequiresPermissions("document:overseas:add")
    @Log(title = "出境申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerOverseasApplication perOverseasApplication)
    {
        return toAjax(perOverseasApplicationService.insertPerOverseasApplication(perOverseasApplication));
    }

    /**
     * 修改出境申请
     */
    @RequiresPermissions("document:overseas:edit")
    @Log(title = "出境申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerOverseasApplication perOverseasApplication)
    {
        return toAjax(perOverseasApplicationService.updatePerOverseasApplication(perOverseasApplication));
    }

    /**
     * 删除出境申请
     */
    @RequiresPermissions("document:overseas:remove")
    @Log(title = "出境申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(perOverseasApplicationService.deletePerOverseasApplicationByIds(ids));
    }
}
